//
//  ContactsTableViewHeaderView.m
//  Findif
//
//  Created by Mac on 2019/2/15.
//  Copyright © 2019年 Cicel Chen. All rights reserved.
//

#import "ContactsTableViewHeaderView.h"

@interface ContactsTableViewHeaderView ()

@property (nonatomic, weak)UIView * lineView;

@end

@implementation ContactsTableViewHeaderView

- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithReuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    return self;
}


- (void)setStatus:(NSString *)status{
    
    _status = status;
    
    if ([status isEqualToString:@"show"]) {
        
        self.statusImageView.image = [UIImage imageNamed:@"多边形下"];
    }else if ([status isEqualToString:@"hidden"]){
        
        self.statusImageView.image = [UIImage imageNamed:@"多边形右"];
    }
}


- (void)setupUI{
    
    self.status = @"hidden";
    
    UIButton * backButton = [UIButton new];
    
    backButton.backgroundColor = ZRWhiteColor;
    
    
    UIImageView * statusImageView = [UIImageView new];
    
    statusImageView.image = [UIImage imageNamed:@"多边形右"];
    statusImageView.userInteractionEnabled = NO;
    
    self.statusImageView = statusImageView;
    
    [self addSubview:self.statusImageView];
    
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = ZRBlackColor;
    titleLabel.font = [UIFont systemFontOfSize:15 * SCREENH6];
    titleLabel.userInteractionEnabled = NO;
    titleLabel.text = @"我的粉丝";
    
    self.titleLabel = titleLabel;
    
    [self addSubview:self.titleLabel];
    
    
    UILabel * countLabel = [UILabel new];
    
    countLabel.textColor = ZRBlackColor;
    countLabel.font = [UIFont systemFontOfSize:13 * SCREENH6];
    countLabel.userInteractionEnabled = NO;
    countLabel.text = @"190";
    
    self.countLabel = countLabel;
    
    [self addSubview:self.countLabel];
    
    
    UIView * lineView = [UIView new];
    
    lineView.backgroundColor = ColorWithRGB(0xe4e4e4);
    
    self.lineView = lineView;
    
    [self addSubview:self.lineView];
}


- (void)layoutSubviews{
    
    [self.statusImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.leading.mas_equalTo(self).offset(15 * SCREENH6);
        make.width.height.mas_equalTo(9 * SCREENH6);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self);
        make.leading.mas_equalTo(self.statusImageView.mas_trailing).offset(10 * SCREENH6);
    }];
    
    [self.countLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.trailing.mas_equalTo(self).offset(-15 * SCREENH6);
        make.centerY.mas_equalTo(self);
    }];
    
    [self.lineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.statusImageView);
        make.trailing.mas_equalTo(self.countLabel);
        make.height.mas_equalTo(1 * SCREENH6);
        make.bottom.mas_equalTo(self);
    }];
}

@end
